package org.jmc.refmanager.web.wicket.page.template;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.jmc.refmanager.web.wicket.markup.html.secured.link.SecuredLink;
import org.jmc.refmanager.web.wicket.page.HomePage;
import org.jmc.refmanager.web.wicket.page.SignOutPage;
import org.jmc.refmanager.web.wicket.page.TestPage;
import org.jmc.refmanager.web.wicket.page.admin.UserFindPage;
import org.jmc.refmanager.web.wicket.page.navigation.AjaxNavigationPage;
import org.jmc.refmanager.web.wicket.page.navigation.NavigationPage;
import org.jmc.refmanager.web.wicket.page.search.ServicesListPage;
import org.jmc.refmanager.web.wicket.page.service.ServiceNewPage;
import org.jmc.refmanager.web.wicket.page.validation.MyGroupTasksListPage;
import org.jmc.refmanager.web.wicket.security.RefManagerAuthenticatedWebSession;

/**
 */
public class TemplatePage extends WebPage {

	/**
	 * @param parameters
	 */
	public TemplatePage(PageParameters parameters) {
		super(parameters);
		initComponents();
	}

	/**
	 * 
	 */
	public TemplatePage() {
		super();
		initComponents();
	}

	private void initComponents() {
        final FeedbackPanel feedback = new FeedbackPanel("infoFeedback");
        add(feedback);

        boolean showTest = false;
		add(new SecuredLink<WebPage>("testLink", TestPage.class).setVisible(showTest));

		add(new BookmarkablePageLink<WebPage>("linkHomePage", HomePage.class));
		add(new SecuredLink<Void>("servicesNavigateLink", AjaxNavigationPage.class));
		add(new SecuredLink<Void>("servicesListLink", ServicesListPage.class));
		add(new SecuredLink<Void>("serviceNewLink", ServiceNewPage.class).setVisible(false));
//		add(new SecuredLink<WebPage>("myTasksListLink", MyTasksListPage.class));
		add(new SecuredLink<WebPage>("myGroupTasksListLink", MyGroupTasksListPage.class));
		add(new SecuredLink<WebPage>("linkUserFindPage", UserFindPage.class));
		
		
		final BookmarkablePageLink<WebPage> signOutLink = 
			new BookmarkablePageLink<WebPage>("signOutLink", SignOutPage.class) {
				private static final long serialVersionUID = 1L;
	            public boolean isVisible() {
	                return RefManagerAuthenticatedWebSession.get().isSignedIn();
	            }
		};
		
        add(signOutLink);
	}
	
}

